/*
 *所有关于tb_project_reviewspecial_group_relation类的业务代码应在此处编写
*可使用repository.调用常用方法，获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*tb_project_reviewspecial_group_relationService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using MYData.Core.BaseProvider;
using MYData.Core.Extensions.AutofacManager;
using MYData.Entity.DomainModels;
using System.Linq;
using MYData.Core.Utilities;
using System.Linq.Expressions;
using MYData.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using MYData.System.IRepositories;
using Microsoft.AspNetCore.Mvc.Rendering;
using MYData.Core.EFDbContext;
using System.Threading.Tasks;
using MYData.System.IServices;

namespace MYData.System.Services
{
    public partial class tb_project_reviewspecial_group_relationService: Itb_project_reviewspecial_group_relationService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly Itb_project_reviewspecial_group_relationRepository _repository;//访问数据库
        private readonly VOLContext _db;
        [ActivatorUtilitiesConstructor]
        public tb_project_reviewspecial_group_relationService(
            Itb_project_reviewspecial_group_relationRepository dbRepository,
            IHttpContextAccessor httpContextAccessor,
            VOLContext db
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _repository = dbRepository;
            _db = db;
            //多租户会用到这init代码，其他情况可以不用
            //base.Init(dbRepository);
        }
        WebResponseContent webResponse = new WebResponseContent();
        /// <summary>
        /// 专家、专家组关系表一对多显示
        /// </summary>
        /// <returns></returns>
        public async Task<WebResponseContent> GetTemplateList()
        {
            var list = from x in _db.Set<tb_project_reviewspecial_group_relation>()
                       join y in _db.Set<tb_project_reviewspecial>().Where(x => x.isDel.Equals(0)) on x.specialistID equals y.specialistID
                       join z in _db.Set<tb_project_reviewspecial_group>().Where(x => x.isDel.Equals(0)) on x.panelID equals z.panelID
                       select new
                       {
                           y.address,
                           y.education,
                           y.specialistName,
                           y.specialistSex,
                           y.specialistJob,
                           y.specialistPhone,
                           y.specialistdatebirth,
                           y.specialistEmail,
                           y.specialistStart,
                           panelID = y.panelID,
                           z.panelName,
                           z.remark,
                       };
            return webResponse.OK("显示成功", list);
        }
    }
}
